package br.com.manutencaocarro.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import br.com.manutencaocarro.R;
 
public class ImageAdapter extends BaseAdapter {
	private Context context;
	private final String[] servicosValues;
 
	public ImageAdapter(Context context, String[] mobileValues) {
		this.context = context;
		this.servicosValues = mobileValues;
	}
 
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
		View gridView;
 
		if (convertView == null) 
		{
			gridView = new View(context);
 
			// get layout from mobile.xml
			gridView = inflater.inflate(R.layout.opcoes, null);
 
			// set image based on selected text
			ImageView imageView = (ImageView) gridView.findViewById(R.id.grid_item_image);
 
			String servico = servicosValues[position];
 
			if (servico.equals("cadastroCarro")) {
				imageView.setImageResource(R.drawable.ic_dodge);
			} else if (servico.equals("cadastroOficina")) {
				imageView.setImageResource(R.drawable.ic_oficina);
			} else if (servico.equals("cadastroPeca")) {
				imageView.setImageResource(R.drawable.ic_peca);
			} else {
				imageView.setImageResource(R.drawable.ic_gerarel);
			}
 
		} else {
			gridView = (View) convertView;
		}
 
		return gridView;
	}
 
	@Override
	public int getCount() {
		return servicosValues.length;
	}
 
	@Override
	public Object getItem(int position) {
		return null;
	}
 
	@Override
	public long getItemId(int position) {
		return 0;
	}
}